<template>
  <div id="main">
    <Theader title="喵喵电影"></Theader>
    <div id="content">
      <div class="movie_menu">
        <router-link tag="div" to="/movie/city" class="city_name active">
          <span>{{ $store.state.city.nm }}</span
          ><i class="iconfont icon-lower-triangle"></i>
        </router-link>
        <div class="hot_swtich">
          <router-link tag="div" to="/movie/nowplaying" class="hot_item"
            >正在热映</router-link
          >
          <router-link tag="div" to="/movie/comingsoon" class="hot_item"
            >即将上映</router-link
          >
        </div>
        <router-link tag="div" to="/movie/search" class="search_entry">
          <i class="iconfont icon-sousuo"></i>
        </router-link>
      </div>
      <keep-alive>
        <router-view></router-view>
      </keep-alive>
    </div>
    <Tfooter></Tfooter>
    <router-view name="detail"></router-view>
  </div>
</template>

<script>
import Theader from "@/components/Theader";
import Tfooter from "@/components/Tfooter";
export default {
  name: "Movie",
  components: { Theader, Tfooter },
  mounted() {
    // 切换地址
    // 当你的定位与当前城市不一致时
    setTimeout(async () => {
      let data = await this.$axios.get("/api/citylocal");
      let nm = data.data.nm;
      let id = data.data.id;
      if (nm != this.$store.state.city.nm) {
        // 弹出弹窗
        this.$confirm("当前城市：深圳", "", {
          // 确认按钮显示的文字
          confirmButtonText: "切换城市",
          // 取消按钮显示的文字
          cancelButtonText: "取消",
          customClass: "winClass", //弹窗样式
        }).then(() => {
          // 把城市信息保存到本地存储中
          window.localStorage.setItem("nm", nm);
          window.localStorage.setItem("id", id);
          // 本地存储修改页面不会刷新数据，手动刷新
          window.location.reload();
        });
      }
    }, 3000);
  },
};
</script>

<style>
#content {
  flex: 1;
  overflow: auto;
  margin-bottom: 50px;
  position: relative;
  display: flex;
  flex-direction: column;
}
.winClass {
  width: 200px;
}
#content .movie_menu {
  width: 100%;
  height: 45px;
  border-bottom: 1px solid #e6e6e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  z-index: 10;
}
.movie_menu .city_name {
  margin-left: 20px;
  height: 100%;
  line-height: 45px;
}
/* .movie_menu .city_name.active {
  color: #ef4238;
  border-bottom: 2px #ef4238 solid;
} */
.movie_menu .city_name.router-link-active {
  color: #ef4238;
  border-bottom: 2px #ef4238 solid;
}
.movie_menu .hot_swtich {
  display: flex;
  height: 100%;
  line-height: 45px;
}
.movie_menu .hot_item {
  font-size: 15px;
  color: #666;
  width: 80px;
  text-align: center;
  margin: 0 12px;
  font-weight: 700;
}
/* .movie_menu .hot_item.active {
  color: #ef4238;
  border-bottom: 2px #ef4238 solid;
} */
.movie_menu .hot_item.router-link-active {
  color: #ef4238;
  border-bottom: 2px #ef4238 solid;
}
.movie_menu .search_entry {
  margin-right: 20px;
  height: 100%;
  line-height: 45px;
}
/* .movie_menu .search_entry.active {
  color: #ef4238;
  border-bottom: 2px #ef4238 solid;
} */
.movie_menu .search_entry.router-link-active {
  color: #ef4238;
  border-bottom: 2px #ef4238 solid;
}

.movie_menu .search_entry i {
  font-size: 24px;
  color: red;
}
</style>